﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using DAL;

namespace BLL
{
    /// <summary>
    /// 
    /// </summary>
    public class CommBLL
    {       
        /// <summary>
        /// 获得单据的流水号
        /// </summary>
        /// <param name="dbOrderNO"> 流水号字段 </param>
        /// <param name="table"> 数据表 </param>
        public static string GetOrderNO(string dbOrderNO, string table)
        {
            string orderNO = "";

            try
            {
                Procedures.P_GetOrderNO(dbOrderNO, table, ref orderNO);
            }
            catch { }

            return orderNO;
        }

        /// <summary>
        /// 获取省份
        /// </summary>
        public static DataTable GetProvince()
        {
            DAL.Tables.tbl_Provinces table = new Tables.tbl_Provinces();
            DataTable dt = table.Open("", "", "");
     
            return dt;
        }

        /// <summary>
        /// 根据获取省份名称获取ID
        /// </summary>
        public static int GetProvinceIDByName(string Name)
        {
            int id = 0;

            DAL.Tables.tbl_Provinces table = new Tables.tbl_Provinces();
            DataTable dt = table.Open("ID", "[Name] = '" + Name+"'", "");

            if (dt != null && dt.Rows.Count > 0)
            {
                id = Shove._Convert.StrToInt(dt.Rows[0]["ID"].ToString(), -1);
            }

            return id;
        }

        /// <summary>
        /// 根据获取省份名称获取城市
        /// </summary>
        public static DataTable GetCity(int ProvinceID)
        {
            DAL.Tables.tbl_Citys table = new DAL.Tables.tbl_Citys();
            DataTable dt = table.Open("", "ProvinceID=" + ProvinceID.ToString() + "", "");

            return dt;
        }
    }
}
